package com.ruoyi.production.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.production.mapper.GreenhousefilmReturnMapper;
import com.ruoyi.production.domain.GreenhousefilmReturn;
import com.ruoyi.production.service.IGreenhousefilmReturnService;

/**
 * 棚膜退回Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-21
 */
@Service
public class GreenhousefilmReturnServiceImpl implements IGreenhousefilmReturnService
{
    @Autowired
    private GreenhousefilmReturnMapper greenhousefilmReturnMapper;

    /**
     * 查询棚膜退回
     *
     * @param greenhousefilmReturnId 棚膜退回ID
     * @return 棚膜退回
     */
    @Override
    public GreenhousefilmReturn selectGreenhousefilmReturnById(Long greenhousefilmReturnId)
    {
        return greenhousefilmReturnMapper.selectGreenhousefilmReturnById(greenhousefilmReturnId);
    }

    /**
     * 查询棚膜退回列表
     *
     * @param greenhousefilmReturn 棚膜退回
     * @return 棚膜退回
     */
    @Override
    public List<GreenhousefilmReturn> selectGreenhousefilmReturnList(GreenhousefilmReturn greenhousefilmReturn)
    {
        return greenhousefilmReturnMapper.selectGreenhousefilmReturnList(greenhousefilmReturn);
    }

    /**
     * 新增棚膜退回
     *
     * @param greenhousefilmReturn 棚膜退回
     * @return 结果
     */
    @Override
    public int insertGreenhousefilmReturn(GreenhousefilmReturn greenhousefilmReturn)
    {
        greenhousefilmReturn.setCreateTime(DateUtils.getNowDate());
//        greenhousefilmReturnMapper.updateGreenhousefilmAmount(greenhousefilmReturn);
        return greenhousefilmReturnMapper.insertGreenhousefilmReturn(greenhousefilmReturn);
    }

    /**
     * 修改棚膜退回
     *
     * @param greenhousefilmReturn 棚膜退回
     * @return 结果
     */
    @Override
    public int updateGreenhousefilmReturn(GreenhousefilmReturn greenhousefilmReturn)
    {
        greenhousefilmReturn.setUpdateTime(DateUtils.getNowDate());
        if(greenhousefilmReturn.getApproval()==1) {
            greenhousefilmReturnMapper.updateGreenhousefilmAmount(greenhousefilmReturn);
            return greenhousefilmReturnMapper.updateGreenhousefilmReturn(greenhousefilmReturn);
        }
        else
            return greenhousefilmReturnMapper.updateGreenhousefilmReturn(greenhousefilmReturn);
    }

    /**
     * 批量删除棚膜退回
     *
     * @param greenhousefilmReturnIds 需要删除的棚膜退回ID
     * @return 结果
     */
    @Override
    public int deleteGreenhousefilmReturnByIds(Long[] greenhousefilmReturnIds)
    {
        return greenhousefilmReturnMapper.deleteGreenhousefilmReturnByIds(greenhousefilmReturnIds);
    }

    /**
     * 删除棚膜退回信息
     *
     * @param greenhousefilmReturnId 棚膜退回ID
     * @return 结果
     */
    @Override
    public int deleteGreenhousefilmReturnById(Long greenhousefilmReturnId)
    {
        return greenhousefilmReturnMapper.deleteGreenhousefilmReturnById(greenhousefilmReturnId);
    }

    /**
     * 获取棚膜类型
     *
     * @param
     * @return 结果
     */
    @Override
    public List<GreenhousefilmReturn> getGreenhousefilmType(){
        return greenhousefilmReturnMapper.getGreenhousefilmType();
    }

    /**
     * 获取用户
     *
     * @param
     * @return 结果
     */
    @Override
    public List<GreenhousefilmReturn> getUserName(){
        return greenhousefilmReturnMapper.getUserName();
    }

    /**
     * 获取棚膜厚度
     *
     * @param greenhousefilmTypeId 棚膜类型ID
     * @return 结果
     */
    @Override
    public List<Double> getThickness(Long greenhousefilmTypeId){
        return greenhousefilmReturnMapper.getThickness(greenhousefilmTypeId);
    }

    /**
     * 获取公司
     *
     * @param greenhousefilmTypeId 棚膜类型ID
     * @return 结果
     */
    @Override
    public List<String> getOriginCompany(Long greenhousefilmTypeId){
        return greenhousefilmReturnMapper.getOriginCompany(greenhousefilmTypeId);
    }
}
